package com.rad.datastat.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * 类说明： 到达统计记录
 * 
 * @author Baker.li
 * @date 2015年1月8日
 * @version 1.0
 */

public class ArrivalPrefs {
	private static final String PREFS_NAME = "settings-1";
	/** 最近发送和接收短信的id，用来判断发送和接收短信 */
	private static final String LAST_SMS_ID = "key-1";
	/** usb是否连接 */
	private static final String USB_CONNECT = "key-2";

	public static final int getLastSMSId(Context context) {
		if (context == null) {
			return 0;
		}
		SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
		return prefs.getInt(LAST_SMS_ID, 0);
	}

	public static final void setLastSMSId(Context context, int id) {
		if (context == null) {
			return;
		}
		SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
		prefs.edit().putInt(LAST_SMS_ID, id).commit();
	}
	
	public static final boolean getUsbConnected(Context context) {
		if (context == null) {
			return false;
		}
		SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
		return prefs.getBoolean(USB_CONNECT, false);
	}

	public static final void setUsbConnected(Context context, boolean connected) {
		if (context == null) {
			return;
		}
		SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
		prefs.edit().putBoolean(USB_CONNECT, connected).commit();
	}

}
